class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        int len=nums.size();
        int cur=0;
        int i=0;
        while(i<nums.size())
        {
            nums[cur++]=nums[i++];
            while(i<nums.size()&&nums[i]==nums[i-1])
            {
                i++;
                len--;
            }
        }
        return len;
    }
};